/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cong.timesheet.action;

import com.cong.timesheet.form.LoginForm;
import com.cong.timesheet.service.UserService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Ram
 */
public class LoginAction extends Action {

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

        LoginForm loginform = (LoginForm) form;
        String username = loginform.getUserName();
        String password = loginform.getPassword();
        UserService userService=new UserService();
        boolean loginResult=userService.checkLogin(username, password);
        if(loginResult==true)
        {
            return mapping.findForward("success");
        }
        else
        {
            return mapping.findForward("failure");
        }
    }
    
    
}
